<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>修改用户信息</title>
    <link rel="stylesheet" th:href="@{/xadmin/css/font.css}"/>
    <link rel="stylesheet" th:href="@{/xadmin/css/xadmin.css}"/>
    <script th:src="@{/xadmin/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/xadmin/js/xadmin.js}"></script>
</head>

<body style="margin-top: 20px;margin-left: 20px;">
<div class="x-body">
    <form class="layui-form">
        <table id="demo" lay-filter="test"></table>
    </form>
</div>
<script>
    layui.use(['form', 'layer', 'laydate', 'table'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate
            , table = layui.table;

        table.render({
            elem: '#demo',
            url: '/extraScore/tutor/list?termId=' + sessionStorage.getItem('termId') + '&timeId=' + sessionStorage.getItem('timeId'),
            // page: true, //开启分页
            cols: [
                [ //表头
                    {type: 'numbers', width: 80, sort: true, title: '序号'},
                    {field: 'username', title: '学号', width: 120, sort: true},
                    {field: 'realName', title: '姓名', width: 80, sort: true},
                    {field: 'score', title: '分数', width: 80},
                    {field: 'remark', title: '备注', width: 177},
                    {
                        title: '状态', width: 80, sort: true,
                        templet: function (d) {
                            if (d.status === -1) {
                                return "<div><span style='color: orange; font-weight: bold;'>待审核</span></div>";
                            } else if (d.status === 0) {
                                return "<div><div><span style='color: red; font-weight: bold;'>不通过</span></div>";
                            } else if (d.status === 1) {
                                return "<div><span style='color: green; font-weight: bold;'>通过</span></div>";
                            } else {
                                return "<div>错误</div>";
                            }
                        }
                    },
                    {
                        field: 'createTime',
                        minWidth: 180,
                        templet: '<div>{{layui.util.toDateString(d.createTime*1, `yyyy-MM-dd HH:mm:ss`)}}</div>',
                        title: '提交时间'
                    },
                    {
                        minWidth: 100,
                        // templet: '<div><button type="button" class="layui-btn">查看</button></div>',
                        templet: function (d) {
                            let clickStr = "onclick='xadmin.open(\"详细信息\",\"/extraScore/tutor/one?id=" + d.id + "&timeId=" + sessionStorage.getItem('timeId') + "\")'";
                            return '<div><button ' + clickStr + ' type="button"  class="layui-btn">详细</button></div>';
                        },
                        title: '详细信息'
                    }
                ]
            ]
        });

        //监听提交
        form.on('submit(add)', function (data) {
            var load = layer.load(2)
            $.ajax({
                url: "/union/score/add",
                type: "POST",
                data: data.field,
                dataType: 'json',
                success: function (result) {
                    layer.close(load)
                    if (result.code === 500 || result.code === 5000100 || result.code === 5000101 || result.code === 5000102) {
                        layer.alert(result.msg, {icon: 2});
                    } else {
                        layer.alert("添加成功", {icon: 6}, function () {
                            //关闭当前frame
                            xadmin.close();
                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });
                    }

                }
            });
            return false;
        });
    });

</script>
</body>
</html>